from django.db import models
from datetime import datetime


# 创意雷达model
class RadarModel(models.Model):
    id = models.AutoField(verbose_name='id', primary_key=True)
    url = models.CharField(max_length=50, verbose_name='链接', default='')
    title = models.CharField(max_length=50, verbose_name='标题', default='')
    img = models.CharField(max_length=80, verbose_name='图片信息', default='')
    source = models.CharField(max_length=20, verbose_name='来源', default='')
    industry = models.CharField(max_length=20, verbose_name='行业', default='')
    hot = models.CharField(max_length=50, verbose_name='热度', default='')
    create_time = models.DateTimeField(verbose_name='创建时间', default='')
    update_time = models.DateTimeField(verbose_name='更新时间', default='')
    logo = models.CharField(max_length=80, verbose_name='logo', default='')
    local_img = models.CharField(max_length=200, verbose_name='本地图片路径', default='暂无')

    class Meta:
        db_table = 'radar_app'
        verbose_name = '创意雷达'
        verbose_name_plural = verbose_name

    def __str__(self):
        return str(self.id)


# 创意雷达副表：副表记录每个广告(包括重复的广告)爬到的时间
class RadarPatameter(models.Model):
    id = models.AutoField(verbose_name='id', primary_key=True)
    radar_ad_id = models.IntegerField(verbose_name='id', default=0)
    time = models.DateTimeField(verbose_name='发现时间', default=datetime.now)

    class Meta:
        db_table = 'radar_ad_to_parameter'
        verbose_name = '雷达统计'
        verbose_name_plural = verbose_name

    def __str__(self):
        return str(self.id)


# 头条model
class ToutiaoModel(models.Model):
    id = models.AutoField(verbose_name='id', primary_key=True)
    article_url = models.CharField(max_length=50, verbose_name='链接', default='')
    title = models.CharField(max_length=80, verbose_name='标题', default='')
    large_image_list = models.CharField(max_length=80, verbose_name='图片信息', default='')
    read_count = models.CharField(max_length=80, verbose_name='浏览次数', default='')
    share_count = models.CharField(max_length=80, verbose_name='分享次数', default='')
    source = models.CharField(max_length=80, verbose_name='广告来源', default='')
    create_time = models.DateTimeField(verbose_name='创建时间', default='')
    update_time = models.DateTimeField(verbose_name='更新时间', default='')
    amount = models.IntegerField(verbose_name='发现次数', default=0)
    local_img = models.CharField(max_length=200, verbose_name='分享次数', default='暂无')

    class Meta:
        db_table = 'toutiao_app'
        verbose_name = '今日头条'
        verbose_name_plural = verbose_name

    def __str__(self):
        return str(self.id)


# 今日头条副表：副表记录每个广告(包括重复的广告)爬到的时间
class ToutiaoPatameter(models.Model):
    id = models.AutoField(verbose_name='id', primary_key=True)
    toutiao_ad_id = models.IntegerField(verbose_name='头条id', default=0)
    toutiao_para_id = models.IntegerField(verbose_name='头条爬虫参数id', default=0)
    time = models.DateTimeField(verbose_name='发现时间', default=datetime.now)

    class Meta:
        db_table = 'toutiao_ad_to_parameter'
        verbose_name = '头条统计'
        verbose_name_plural = verbose_name

    def __str__(self):
        return str(self.id)


# 新浪model
class SinaModel(models.Model):
    id = models.AutoField(verbose_name='id', primary_key=True)
    link = models.CharField(max_length=50, verbose_name='链接', default='')
    title = models.CharField(max_length=80, verbose_name='标题', default='')
    pic = models.CharField(max_length=80, verbose_name='图片信息', default='')
    create_time = models.DateTimeField(verbose_name='创建时间', default='')
    update_time = models.DateTimeField(verbose_name='更新时间', default='')
    amount = models.IntegerField(verbose_name='发现次数', default=0)
    local_img = models.CharField(max_length=200, verbose_name='本地图片路径', default='暂无')

    class Meta:
        db_table = 'sina_app'
        verbose_name = '新浪新闻'
        verbose_name_plural = verbose_name

    def __str__(self):
        return str(self.id)


# 新浪副本model：副表记录每个广告(包括重复的广告)爬到的时间
class SinaPatameter(models.Model):
    id = models.AutoField(verbose_name='id', primary_key=True)
    sina_ad_id = models.IntegerField(verbose_name='id', default=0)
    sina_para_id = models.IntegerField(verbose_name='爬虫参数id', default=0)
    time = models.DateTimeField(verbose_name='发现时间', default=datetime.now)

    class Meta:
        db_table = 'sina_ad_to_parameter'
        verbose_name = '新浪统计'
        verbose_name_plural = verbose_name

    def __str__(self):
        return str(self.id)


# 搜狐model
class SouhuModel(models.Model):
    id = models.AutoField(verbose_name='id', primary_key=True)
    link = models.CharField(max_length=50, verbose_name='链接', default='')
    resource_text = models.CharField(max_length=80, verbose_name='标题', default='')
    resource1 = models.CharField(max_length=80, verbose_name='图片信息', default='')
    resource2 = models.CharField(max_length=80, verbose_name='图片信息2', default='')
    create_time = models.DateTimeField(verbose_name='创建时间', default='')
    update_time = models.DateTimeField(verbose_name='更新时间', default='')
    amount = models.IntegerField(verbose_name='发现次数', default=0)
    local_img = models.CharField(max_length=200, verbose_name='本地图片路径', default='暂无')

    class Meta:
        db_table = 'souhu_app'
        verbose_name = '新浪新闻'
        verbose_name_plural = verbose_name

    def __str__(self):
        return str(self.id)


# souhu副表：副表记录每个广告(包括重复的广告)爬到的时间
class SouhuPatameter(models.Model):
    id = models.AutoField(verbose_name='id', primary_key=True)
    souhu_ad_id = models.IntegerField(verbose_name='id', default=0)
    souhu_para_id = models.IntegerField(verbose_name='爬虫参数id', default=0)
    time = models.DateTimeField(verbose_name='发现时间', default=datetime.now)

    class Meta:
        db_table = 'souhu_ad_to_parameter'
        verbose_name = '搜狐统计'
        verbose_name_plural = verbose_name

    def __str__(self):
        return str(self.id)


# 凤凰model
class FenghuangModel(models.Model):
    id = models.AutoField(verbose_name='id', primary_key=True)
    weburl = models.CharField(max_length=50, verbose_name='链接', default='')
    title = models.CharField(max_length=80, verbose_name='标题', default='')
    thumbnail = models.CharField(max_length=80, verbose_name='图片信息', default='')
    source = models.CharField(max_length=20, verbose_name='来源', default='')
    create_time = models.DateTimeField(verbose_name='创建时间', default='')
    update_time = models.DateTimeField(verbose_name='更新时间', default='')
    amount = models.IntegerField(verbose_name='发现次数', default=0)
    local_img = models.CharField(max_length=150, verbose_name='本地图片路径', default='暂无')

    class Meta:
        db_table = 'fenghuang_app'
        verbose_name = '凤凰新闻'
        verbose_name_plural = verbose_name

    def __str__(self):
        return str(self.id)


# 凤凰副表：副表记录每个广告(包括重复的广告)爬到的时间
class FenghuangPatameter(models.Model):
    id = models.AutoField(verbose_name='id', primary_key=True)
    fenghuang_ad_id = models.IntegerField(verbose_name='id', default=0)
    fenghuang_para_id = models.IntegerField(verbose_name='爬虫参数id', default=0)
    time = models.DateTimeField(verbose_name='发现时间', default=datetime.now)

    class Meta:
        db_table = 'fenghuang_ad_to_parameter'
        verbose_name = '凤凰统计'
        verbose_name_plural = verbose_name

    def __str__(self):
        return str(self.id)


class FeedsradarModel(models.Model):
    id = models.AutoField(verbose_name='id', primary_key=True)
    title = models.CharField(verbose_name='标题', max_length=100, default='')
    img = models.CharField(verbose_name='图片路径', max_length=100, default='')
    publish_time = models.CharField(verbose_name='发现时间', max_length=100, default='')
    advertiser = models.CharField(verbose_name='广告主', max_length=50, default='')
    industry = models.CharField(verbose_name='行业', max_length=20, default='')
    source = models.CharField(verbose_name='来源', max_length=20, default='')
    target = models.CharField(verbose_name='投放目标', max_length=20, default='')
    url = models.CharField(verbose_name='广告链接', max_length=100, default='')
    range_date = models.CharField(verbose_name='投放日期范围', max_length=30, default='')
    cound_date = models.CharField(verbose_name='投放天数', max_length=20, default='')
    min_index = models.CharField(verbose_name='最小指数', max_length=20, default='')
    max_index = models.CharField(verbose_name='最大指数', max_length=20, default='')
    avg_index = models.CharField(verbose_name='平均指数', max_length=20, default='')
    update_time = models.CharField(verbose_name='最近发现时间', max_length=20, default='')
    create_time = models.CharField(verbose_name='创建时间', max_length=20, default='')
    discover_count = models.IntegerField(verbose_name='发现次数', default=0)
    local_img = models.CharField(verbose_name='本地图片路径', max_length=50, default='暂无')
    un_watermark = models.CharField(verbose_name='去水印图片', max_length=50, default='暂无')

    class Meta:
        db_table = 'feedsradar_app'
        verbose_name = '信息流雷达'
        verbose_name_plural = verbose_name

    def __str__(self):
        return str(self.id)


class FeedsradarParameter(models.Model):
    id = models.AutoField(verbose_name='id', primary_key=True)
    feedsradar_ad_id = models.IntegerField(verbose_name='id', default=0)
    time = models.DateTimeField(verbose_name='发现时间', default=datetime.now)

    class Meta:
        db_table = 'feedsradar_ad_to_parameter'
        verbose_name = '信息流雷达统计'
        verbose_name_plural = verbose_name

    def __str__(self):
        return str(self.id)


class toutiao_2_model(models.Model):
    id = models.AutoField(verbose_name='id', primary_key=True)
    title = models.CharField(verbose_name='标题', max_length=50, default='')
    image = models.CharField(verbose_name='图片路径', max_length=150, default='')
    web_url = models.CharField(verbose_name='头条广告链接', max_length=100, default='')
    source = models.CharField(verbose_name='来源', max_length=20, default='')
    local_img = models.CharField(verbose_name='本地图片路径', max_length=50, default='暂无')
    ad_url = models.CharField(verbose_name='广告原始链接', max_length=100, default='')
    update_time = models.CharField(verbose_name='最近发现时间', max_length=20, default='')
    create_time = models.CharField(verbose_name='创建时间', max_length=20, default='')

    class Meta:
        db_table = 'toutiao_app_2'
        verbose_name = '头条二级广告'
        verbose_name_plural = verbose_name

    def __str__(self):
        return str(self.id)
